//------------------------------------------------------------------------------
//  <copyright file="ClientMessage.cpp" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//  </copyright>
//------------------------------------------------------------------------------

#include "stdafx.h"
#include "KukaLBR4PlusControllerExports.h"
#include "ClientMessages.h"

#include <KukaLBR4Definitions.h>

KukaWorkingRegisterMessage::KukaWorkingRegisterMessage()
{
	this->ControllerStrategyCommandRegister = 0;
	this->CurrentControllerStateNumber = 0;
	this->Scalar1Register = 0;
	this->Scalar2Register = 0;
	this->Scalar3Register = 0;
	this->Scalar4Register = 0;
	this->Scalar5Register = 0;
	this->Scalar6Register = 0;
	this->Scalar7Register = 0;
	this->Scalar8Register = 0;

	for (unsigned int i = 0; i < NUM_JOINTS; ++i)
	{
		this->JointPositionCommandRegister[i] = 0;
		this->JointTorqueCommandRegister[i] = 0;
		this->JointStiffnessCommandRegister[i] = 0;
		this->JointDampingCommandRegister[i] = 0;
		this->JointVec1Register[i] = 0;
		this->JointVec2Register[i] = 0;
		this->JointVec3Register[i] = 0;
	}

	for (unsigned int i = 0; i < CARTESIAN_DIM; ++i)
	{
		this->TCPForceTorqueCommandRegister[i] = 0;
		this->CartesianStiffnessCommandRegister[i] = 0;
		this->CartesianDampingCommandRegister[i] = 0;
		this->CartVec1Register[i] = 0;
		this->CartVec2Register[i] = 0;
		this->CartVec3Register[i] = 0;
	}

	for (unsigned int i = 0; i < CARTESIAN_FRAME_LENGTH; ++i)
	{
		this->CartesianPositionCommandRegister[i] = 0;
		this->Frame1Register[i] = 0;
		this->Frame2Register[i] = 0;
		this->Frame3Register[i] = 0;
	}
}

KukaFeedbackMessage::KukaFeedbackMessage()
{
	this->ControllerStrategyCommandRegister = 0;
	this->CurrentControllerStateNumber = 0;
	this->Scalar1Register = 0;
	this->Scalar2Register = 0;
	this->Scalar3Register = 0;
	this->Scalar4Register = 0;
	this->Scalar5Register = 0;
	this->Scalar6Register = 0;
	this->Scalar7Register = 0;
	this->Scalar8Register = 0;
    this->TimestampInMsRegister = 0;
	this->FriStateRegister = 0;
	this->UdpQualityRegister = 0;
	this->CycleTimeInMsRegister = 0;
	this->SafetyLimitInPercentRegister = 0;
	this->DrivePowerBitFieldRegister = 0;
	this->ControllerStrategyRegister = 0;

	for (unsigned int i = 0; i < NUM_JOINTS; ++i)
	{
		this->JointPositionCommandRegister[i] = 0;
		this->JointTorqueCommandRegister[i] = 0;
		this->JointStiffnessCommandRegister[i] = 0;
		this->JointDampingCommandRegister[i] = 0;
		this->JointVec1Register[i] = 0;
		this->JointVec2Register[i] = 0;
		this->JointVec3Register[i] = 0;
		this->JointTemperatureRegister[i] = 0;
		this->MeasuredJointPositionRegister[i] = 0;
		this->MeasuredJointVelocityRegister[i] = 0;
		this->ReportedCommandedJointPositionRegister[i] = 0;
		this->ReportedCommandedJointOffsetRegister[i] = 0;
		this->MeasuredJointTorqueRegister[i] = 0;
		this->MeasuredExternalJointTorqueRegister[i] = 0;
		this->GravityCompensationRegister[i] = 0;
		this->LastIssuedJointPositionCommandRegister[i] = 0;
	}

	for (unsigned int i = 0; i < CARTESIAN_DIM; ++i)
	{
		this->TCPForceTorqueCommandRegister[i] = 0;
		this->CartesianStiffnessCommandRegister[i] = 0;
		this->CartesianDampingCommandRegister[i] = 0;
		this->CartVec1Register[i] = 0;
		this->CartVec2Register[i] = 0;
		this->CartVec3Register[i] = 0;
		this->EstimatedTCPForceTorqueRegister[i] = 0;
	}

	for (unsigned int i = 0; i< CARTESIAN_FRAME_LENGTH; ++i)
	{
		this->CartesianPositionCommandRegister[i] = 0;
		this->Frame1Register[i] = 0;
		this->Frame2Register[i] = 0;
		this->Frame3Register[i] = 0;
		this->MeasuredCartesianPositionRegister[i] = 0;
		this->ReportedCommandedCartesianPositionRegister[i] = 0;
		this->ReportedCommandedCartesianOffsetRegister[i] = 0;
	}

	for (unsigned int i = 0; i < CARTESIAN_DIM * NUM_JOINTS; ++i)
	{
		this->JacobianRegister[i] = 0;
		this->MassMatrixRegister[i] = 0;
	}
}
